layui.use(['table', 'admin', 'ax'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;

    /**
     * 拣货单明细表管理
     */
    var StorageOutDetailed = {
        tableId: "storageOutDetailedTable"
    };

    /**
     * 初始化表格的列
     */
    StorageOutDetailed.initColumn = function () {
        return [[
            {field: 'id', hide: true, title: 'Primary Key ID'},
            {field: 'storageOutStatus', sort: true, title: 'Picking Status',templet: '#storageOutStatusTpl'},
            {field: 'storageOutName', sort: true, title: 'Picking Staff'},
            {field: 'updateTime', sort: true, title: 'Picking Time'},
            {field: 'storageOutNumber', sort: true, title: 'Picking Order Number'},
            {field: 'trayNumber', sort: true, title: 'Tray Number'},
            {field: 'storagePostionNumber', sort: true, title: 'Storage Location Number'},
            {field: 'storageGoodscode', sort: true, title: 'Product Code'},
            {field: 'storageGoodsname', sort: true, title: 'Product Name'},
            {field: 'goodsNo', sort: true, title: 'Item Number', totalRowText: 'Total:'},
            {field: 'storageNumber', sort: true, title: 'Quantity', totalRow: true},
            {field: 'realNum', sort: true, title: 'Actual Quantity', totalRow: true},
            {field: 'recommendBatchs', sort: true, title: 'Inbound Batch'},
            {field: 'storageDate', sort: true, title: 'Production Date', style:'background-color: #dbf1e1;font-weight: 600;'},
            {field: 'storageBatchnumber', sort: true, title: 'Batch Number', style:'background-color: #dbf1e1;font-weight: 600;'},
            {field: 'storageWeight', sort: true, title: 'Weight', totalRow: true},
            {field: 'storageVolume', sort: true, title: 'Volume', totalRow: true},
            {field: 'storagePrice', title: 'Unit Price'},
            {field: 'storageMoney', sort: true, title: 'Amount', totalRow: true},
            {field: 'storageLargeclass', title: 'Category'},
            {field: 'storageGoodstype', title: 'Type', hide: true},
            {field: 'goodsUnit', title: 'Unit'},
            {field: 'storagePacking', title: 'Packaging'},
            {field: 'goodsSpecs', title: 'Specifications'},
        ]];
    };

    /**
     * 点击查询按钮
     */
    StorageOutDetailed.search = function () {
        var queryData = {};
        queryData['condition'] = $("#condition").val();
        table.reload(StorageOutDetailed.tableId, {
            where: queryData, page: {curr: 1},
             done:function () {
            }
        });
    };

    // 渲染表格
    var tableResult = table.render({
        elem: '#' + StorageOutDetailed.tableId,
        url: Feng.ctxPath + '/storageOutDetailed/querylist?storageOutNumber='+$("#storageOutNumber").val(),
        page: true,
        limit: 40,
        height: "full-60",
        toolbar: '#toolbarfrom',
        cellMinWidth: 100,
        totalRow: true ,//开启合计行
        cols: StorageOutDetailed.initColumn()
    });

    // 搜索按钮点击事件
    $('#btnSearch').click(function () {
        StorageOutDetailed.search();
    });

});
